home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / mole.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  8KB  |  261 lines

  1. //    MOLE ATTACK    YACHIYO  1982
  2. //    known clones: "Holy Moly"
  3. //
  4. //    emulated by Jason Nelson, Phil Stroffolino
  5. //    known issues:
  6. //        some dips not mapped
  7. //        protection isn't fully understood, but game seems to be
  8. //        ok.
  9. //
  10. //    buttons are laid out as follows:
  11. //    7    8    9
  12. //    4    5    6
  13. //    1    2    3
  14. //
  15. // Working RAM notes:
  16. // 0x2e0                    number of credits
  17. // 0x2F1                    coin up trigger
  18. // 0x2F2                    round counter
  19. // 0x2F3                    flag value
  20. // 0x2FD                    hammer aim for attract mode
  21. // 0x2E1-E2                    high score
  22. // 0x2ED-EE                    score
  23. // 0x301-309                presence and height of mole in each hole, from bottom left
  24. // 0x30a
  25. // 0x32E-336                if a hammer is above a mole. (Not the same as collision)
  26. // 0x337                    dip switch related
  27. // 0x338                    dip switch related
  28. // 0x340                    hammer control: manual=0; auto=1
  29. // 0x34C                    round point 10s.
  30. // 0x34D                    which bonus round pattern to use for moles.
  31. // 0x349                    button pressed (0..8 / 0xff)
  32. // 0x350                    number of players
  33. // 0x351                    irq-related
  34. // 0x361
  35. // 0x362
  36. // 0x363
  37. // 0x364
  38. // 0x366                    mirrors tile bank
  39. // 0x36B                    controls which player is playing. (1 == player 2);
  40. // 0x3DC                    affects mole popup
  41. // 0x3E5                    round point/passing point control?
  42. // 0x3E7                    round point/passing point control?
  43.  
  44. #include "driver.h"
  45. #include "vidhrdw/generic.h"
  46.  
  47. extern void moleattack_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  48. extern int moleattack_vh_start( void );
  49. extern void moleattack_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  50. extern void moleattack_vh_stop( void );
  51.  
  52. WRITE_HANDLER( moleattack_videoram_w );
  53. WRITE_HANDLER( moleattack_tilesetselector_w );
  54.  
  55. static struct GfxLayout tile_layout =
  56. {
  57.     8,8,    /* character size */
  58.     512,    /* number of characters */
  59.     3,        /* number of bitplanes */
  60.     { 0x0000*8, 0x1000*8, 0x2000*8 },
  61.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  62.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  63.     8*8
  64. };
  65.  
  66. static struct GfxDecodeInfo gfx_decode[] = {
  67.     { 1, 0x0000, &tile_layout, 0x00, 1 },
  68.     { 1, 0x3000, &tile_layout, 0x00, 1 },
  69.     { -1 }
  70. };
  71.  
  72. static struct AY8910interface ay8910_interface =
  73. {
  74.     1,    /* 1 chip */
  75.     2000000, /* 2 MHz? */
  76.     { 100 }, /* volume */
  77.     { 0 },
  78.     { 0 },
  79.     { 0 },
  80.     { 0 }
  81. };
  82.  
  83. READ_HANDLER( mole_prot_r ){
  84.     /*    Following are all known examples of Mole Attack
  85.     **    code reading from the protection circuitry:
  86.     **
  87.     **    5b0b:
  88.     **    ram[0x0361] = (ram[0x885+ram[0x8a5])&ram[0x886]
  89.     **    ram[0x0363] = ram[0x886]
  90.     **
  91.     **    53c9:
  92.     **    ram[0xe0] = ram[0x800]+ram[0x802]+ram[0x804]
  93.     **    ram[0xea] = ram[0x828]
  94.     **
  95.     **    ram[0xe2] = (ram[0x806]&ram[0x826])|ram[0x820]
  96.     **    ram[0xe3] = ram[0x826]
  97.     **
  98.     **    ram[0x361] = (ram[0x8cd]&ram[0x8ad])|ram[0x8ce]
  99.     **    ram[0x362] = ram[0x8ae] = 0x32
  100.     **
  101.     **    ram[0x363] = ram[0x809]+ram[0x829]+ram[0x828]
  102.     **    ram[0x364] = ram[0x808]
  103.     */
  104.  
  105.     switch( offset ){
  106.     case 0x08: return 0xb0; /* random mole placement */
  107.     case 0x26:
  108.         if( cpu_get_pc() == 0x53d7 ){
  109.             return 0x06; /* bonus round */
  110.         }
  111.         else { // pc == 0x515b, 0x5162
  112.             return 0xc6; /* game start */
  113.         }
  114.     case 0x86: return 0x91; /* game over */
  115.     case 0xae: return 0x32; /* coinage */
  116.     }
  117.  
  118.     /*    The above are critical protection reads.
  119.     **    It isn't clear what effect (if any) the
  120.     **    remaining reads have; for now we simply
  121.     **    return 0x00
  122.     */
  123.     return 0x00;
  124. }
  125.  
  126. static struct MemoryReadAddress moleattack_readmem[] =
  127. {
  128.     { 0x0000, 0x03ff, MRA_RAM },
  129.     { 0x0800, 0x08ff, mole_prot_r },
  130.     { 0x5000, 0x7fff, MRA_ROM },
  131.     { 0x8d00, 0x8d00, input_port_0_r },
  132.     { 0x8d40, 0x8d40, input_port_1_r },
  133.     { 0x8d80, 0x8d80, input_port_2_r },
  134.     { 0x8dc0, 0x8dc0, input_port_3_r },
  135.     { 0xd000, 0xffff, MRA_ROM },
  136.     { -1 }
  137. };
  138.  
  139. static struct MemoryWriteAddress moleattack_writemem[] =
  140. {
  141.     { 0x0000, 0x03ff, MWA_RAM },
  142.     { 0x5000, 0x7fff, MWA_ROM },
  143.     { 0x8000, 0x83ff, moleattack_videoram_w },
  144.     { 0x8400, 0x8400, moleattack_tilesetselector_w},
  145.     { 0x8c00, 0x8c00, AY8910_write_port_0_w },
  146.     { 0x8c01, 0x8c01, AY8910_control_port_0_w },
  147.     { 0x8d00, 0x8d00, MWA_NOP }, /* watchdog? */
  148.     { 0xd000, 0xffff, MWA_ROM },
  149.     { -1 }
  150. };
  151.  
  152. struct MachineDriver machine_driver_mole =
  153. {
  154.     {
  155.         {
  156.             CPU_M6502,
  157.             4000000, /* ? */
  158.             moleattack_readmem,moleattack_writemem,0,0,
  159.             interrupt,1
  160.         }
  161.     },
  162.     60, DEFAULT_60HZ_VBLANK_DURATION,
  163.     1, /* single CPU */
  164.     0,
  165.     /* video hardware */
  166.     40*8, 25*8, { 0*8, 40*8-1, 0*8, 25*8-1 },
  167.     gfx_decode,
  168.     8,8,moleattack_vh_convert_color_prom,
  169.     VIDEO_TYPE_RASTER,
  170.     0,
  171.     moleattack_vh_start,
  172.     moleattack_vh_stop,
  173.     moleattack_vh_screenrefresh,
  174.     0,0,0,0,
  175.     {
  176.         {
  177.             SOUND_AY8910,
  178.             &ay8910_interface
  179.         }
  180.     }
  181. };
  182.  
  183. ROM_START( mole ) /* ALL ROMS ARE 2732 */
  184.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for 6502 code */
  185.     ROM_LOAD( "m3a.5h",    0x5000, 0x1000, 0x5fbbdfef )
  186.     ROM_RELOAD(            0xd000, 0x1000)
  187.     ROM_LOAD( "m2a.7h",    0x6000, 0x1000, 0xf2a90642 )
  188.     ROM_RELOAD(            0xe000, 0x1000 )
  189.     ROM_LOAD( "m1a.8h",    0x7000, 0x1000, 0xcff0119a )
  190.     ROM_RELOAD(            0xf000, 0x1000 )
  191.  
  192.     ROM_REGION( 0x6000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  193.     ROM_LOAD( "mea.4a",    0x0000, 0x1000, 0x49d89116 )
  194.     ROM_LOAD( "mca.6a",    0x1000, 0x1000, 0x04e90300 )
  195.     ROM_LOAD( "maa.9a",    0x2000, 0x1000, 0x6ce9442b )
  196.     ROM_LOAD( "mfa.3a",    0x3000, 0x1000, 0x0d0c7d13 )
  197.     ROM_LOAD( "mda.5a",    0x4000, 0x1000, 0x41ae1842 )
  198.     ROM_LOAD( "mba.8a",    0x5000, 0x1000, 0x50c43fc9 )
  199. ROM_END
  200.  
  201. INPUT_PORTS_START( mole )
  202.     PORT_START // 0x8d00
  203.     PORT_DIPNAME( 0x01, 0x00, "Round Points" )
  204.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  205.     PORT_DIPSETTING(    0x01, DEF_STR( On ) )
  206.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Coinage ) )
  207.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  208.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  209.     PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Unknown ) )
  210.     PORT_DIPSETTING(    0x00, "A" )
  211.     PORT_DIPSETTING(    0x04, "B" )
  212.     PORT_DIPSETTING(    0x08, "C" )
  213.     PORT_DIPSETTING(    0x0c, "D" )
  214.     PORT_DIPNAME( 0x30, 0x00, DEF_STR( Unknown ) )
  215.     PORT_DIPSETTING(    0x00, "A" )
  216.     PORT_DIPSETTING(    0x10, "B" )
  217.     PORT_DIPSETTING(    0x20, "C" )
  218.     PORT_DIPSETTING(    0x30, "D" )
  219.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) ) /* unused */
  220.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  221.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  222.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) ) /* unused */
  223.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  224.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  225.  
  226.     PORT_START // 0x8d40
  227.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 )
  228.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 )
  229.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 )
  230.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 )
  231.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5 )
  232.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 )
  233.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7 )
  234.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON8 )
  235.  
  236.     PORT_START // 0x8d80
  237.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 )
  238.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL )
  239.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL )
  240.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_COCKTAIL )
  241.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Cabinet ) )
  242.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  243.     PORT_DIPSETTING(    0x10, DEF_STR( Cocktail ) )
  244.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 )
  245.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START1 )
  246.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 )
  247.  
  248.     PORT_START // 0x8dc0
  249.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON8 | IPF_COCKTAIL )
  250.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON7 | IPF_COCKTAIL )
  251.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 | IPF_COCKTAIL )
  252.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON9 | IPF_COCKTAIL )
  253.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON6 | IPF_COCKTAIL )
  254.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON5 | IPF_COCKTAIL )
  255.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  256.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  257. INPUT_PORTS_END
  258.  
  259.  
  260. GAME( 1982, mole, 0, mole, mole, 0, ROT0, "Yachiyo Electronics, Ltd.", "Mole Attack" )
  261.